<?php

namespace app\admin\controller;


use app\common\model\StudentFankui;
use app\common\model\Wenjuan as WenjuanModel;
use app\common\model\WenjuanFankui;
use app\common\model\StudentFupan;

class Wenjuan extends Base
{

    public function __construct()
    {
        parent::__construct();
    }


    /**
     * 列表
     * @return \think\response\Json
     */
    public function list()
    {
        $where = array();
        if (input('name', ''))
            $where['name'] = array('like', "%" . input('name', '') . "%");
        $page = max(input('page'), 1);
        $size = 20;
        $list = WenjuanModel::getPage($where, $page, $size);
        $total = WenjuanModel::getCount($where);
        if (!$list) {
            $list = [];
            return returnJson(0, '', compact('list', 'total', 'page', 'size'));
        }
        return returnJson(0, '', [
            'list' => $list,
            'size' => $size,
            'total' => $total,
            'page' => $page
        ]);
    }




    /**
     * 反馈
     */
    public function fankui(){
        $save = input('');
        if(request()->isPost()){
            $time = time();
            $save['update_time'] = $time;
            $save['create_time'] = $time;
            $save['mid'] = $this->manager['id'];
            WenjuanFankui::setInsertGetId($save);

            WenjuanModel::setIncr(['id'=>['eq',$save['wid']]],'status');

            return returnJson(0, '操作成功');
        }
        return returnJson(1, '网络异常，请重试');
    }



}

